<?php
declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    protected $table = 'data_articles';
    protected $dateFormat = 'U';
    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';
    const DELETED_AT = 'delete_time';

    public function content()
    {
        return $this->hasOne(ArticleContent::class, 'article_id', 'id');
    }

    public function category()
    {
        return $this->belongsTo(ArticleCategory::class, 'cate_id', 'id');
    }

    public function tags()
    {
        return $this->belongsToMany(Tags::class, 'data_article_tag', 'article_id', 'tag_id')->using(ArticleTag::class);
    }
}
